home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / c / rel_sun3.c < prev    next >
C/C++ Source or Header  |  1988-12-10  |  1KB  |  46 lines

  1.  
  2. /* Copyright William Schelter. All rights reserved.  This file does
  3. the low level relocation which tends to be very system dependent.
  4. It is included by the file sfasl.c
  5. */
  6.  
  7. relocate()
  8. {
  9.  char *where;
  10.  
  11.   {unsigned int new_value;
  12.    where = the_start + relocation_info.r_address;
  13.    if(relocation_info.r_extern)
  14.      {
  15.        if (relocation_info.r_pcrel)
  16.      new_value=   - (int)start_address
  17.        + symbol_table[relocation_info.r_symbolnum].n_value;
  18.        else
  19.      { new_value= 
  20.          symbol_table[relocation_info.r_symbolnum].n_value;}}
  21.    else
  22.      { switch(relocation_info.r_symbolnum){
  23.      case N_DATA: case N_BSS: case N_TEXT:
  24.        new_value= (int)start_address;
  25.        break;
  26.      default:
  27.        dprintf(relocation_info.r_extern = %d, relocation_info.r_extern);
  28.        printf("\nrelocation_info {r_symbolnum= %d, r_address = %d, r_extern=0 Ignored:",relocation_info.r_address,
  29.           relocation_info.r_symbolnum);fflush(stdout);
  30.        goto DONT;}
  31.      };
  32.    switch(relocation_info.r_length){
  33.    case 0:
  34.      *( char *)where = new_value + *( char *) where; break;
  35.    case 1:
  36.      *( short *)where = new_value + *( short *) where; break;
  37.    case 2:
  38.      *( long *)where = new_value + *( long *) where; break;
  39.    }
  40.  DONT:;
  41.  }
  42. }
  43.  
  44.  
  45.  
  46.